<!DOCTYPE HTML>
<html>
<head>
  <meta charset="utf-8">
  
  <title>第 2 页 | ChenBlue | 飞雪连天射白鹿 笑书神侠倚碧鸳</title>

  
  <meta name="author" content="ChenBlue">
  

  
  <meta name="description" content="学习笔记">
  

  

  <meta id="viewport" name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, minimal-ui">
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">

  

  <meta property="og:site_name" content="ChenBlue"/>

  
  <meta property="og:image" content="/blog/favicon.ico"/>
  

  <link href="/blog/favicon.ico" rel="icon">
  <link rel="alternate" href="/blog/atom.xml" title="ChenBlue" type="application/atom+xml">
  <link rel="stylesheet" href="/blog/css/style.css" media="screen" type="text/css">
<meta name="generator" content="Hexo 5.4.0"></head>


<body>
<div class="blog">
  <div class="content">

    <header>
  <div class="site-branding">
    <h1 class="site-title">
      <a href="/blog/">ChenBlue</a>
    </h1>
    <p class="site-description">飞雪连天射白鹿 笑书神侠倚碧鸳</p>
  </div>
  <nav class="site-navigation">
    <ul>
      
    </ul>
  </nav>
</header>

    <main class="site-main posts-loop">
    
  <article>

  
    
    <h3 class="article-title"><a href="/blog/2021/04/12/4-机器人模型 URDF 及 XACRO/"><span>4-机器人模型 URDF 及 XACRO</span></a></h3>
    
  

  <div class="article-top-meta">
    <span class="posted-on">
      <a href="/blog/2021/04/12/4-机器人模型 URDF 及 XACRO/" rel="bookmark">
        <time class="entry-date published" datetime="2021-04-12T12:39:03.000Z">
          2021-04-12
        </time>
      </a>
    </span>
  </div>


  

  <div class="article-content">
    <div class="entry">
      
        <h1 id="URDF-机器人模型"><a href="#URDF-机器人模型" class="headerlink" title="URDF 机器人模型"></a>URDF 机器人模型</h1><h2 id="URDF-模型的两个重要属性"><a href="#URDF-模型的两个重要属性" class="headerlink" title="URDF 模型的两个重要属性"></a>URDF 模型的两个重要属性</h2><h3 id="link"><a href="#link" class="headerlink" title="link"></a>link</h3><blockquote>
<p>描述机器人某个刚体部分的外观和物理属性;</p>
<p>描述连杆尺寸(size)、颜色(color)，形状(shape) 惯性矩阵(inertial matrix)，碰撞参数(collision properties)等。</p>
<p>每个Link会成为一个坐标系</p>
</blockquote>
<pre class="language-html" data-language="html"><code class="language-html"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>link</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>link 4<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>visual</span><span class="token punctuation">></span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>geometry</span><span class="token punctuation">></span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>mesh</span> <span class="token attr-name">filename</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>link 4.stl<span class="token punctuation">"</span></span><span class="token punctuation">/></span></span>
        &lt;/ geometry>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>origin</span> <span class="token attr-name">xyz</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>0 0 0<span class="token punctuation">"</span></span> <span class="token attr-name">rpy</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>0 0 0<span class="token punctuation">"</span></span><span class="token punctuation">/></span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>visual</span><span class="token punctuation">></span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>collision</span><span class="token punctuation">></span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>geometry</span><span class="token punctuation">></span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>cylinder</span> <span class="token attr-name">length</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>0.5<span class="token punctuation">"</span></span> <span class="token attr-name">radius</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>0.1<span class="token punctuation">"</span></span><span class="token punctuation">/></span></span>
        &lt;/ geometry>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>origin</span> <span class="token attr-name">xyz</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>0 0 -o.05<span class="token punctuation">"</span></span><span class="token attr-name">rpy</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>0 0 0<span class="token punctuation">"</span></span><span class="token punctuation">/></span></span>
    &lt;/ collision>
&lt;/ link></code></pre>

<h3 id="joint"><a href="#joint" class="headerlink" title="joint"></a>joint</h3><blockquote>
<p>描述两个link之间的关系，分为六种类型;</p>
<p>包括关节运动的位置和速度限制;</p>
<p>描述机器人关节的运动学和动力学属性。</p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">关节类型</th>
<th align="center">描述</th>
</tr>
</thead>
<tbody><tr>
<td align="center">continuous</td>
<td align="center">旋转关节，可以围绕单轴无限旋转</td>
</tr>
<tr>
<td align="center">revolute</td>
<td align="center">旋转关节，类似于continuous 但是有旋转的角度极限</td>
</tr>
<tr>
<td align="center">prismatic</td>
<td align="center">滑动关节，沿某一轴线性移动的关节，带有位置极限</td>
</tr>
<tr>
<td align="center">planar</td>
<td align="center">平面关节，允许在平面正交方向上平移或者旋转</td>
</tr>
<tr>
<td align="center">floating</td>
<td align="center">浮动关节，允许进行平移、旋转运动</td>
</tr>
<tr>
<td align="center">fixed</td>
<td align="center">固定关节，不允许运动的特殊关节</td>
</tr>
</tbody></table>
<pre class="language-none"><code class="language-none">&lt;joint name&#x3D;&quot;joint_2&quot; type&#x3D;&quot;revolute &quot;&gt;
    &lt;parent link&#x3D; &quot;link_1&quot;&#x2F;&gt;
    &lt;child link&#x3D; &quot;link_2&quot;&#x2F;&gt;
    &lt;origin xyz&#x3D;&quot;0.2 0.2 0&quot; rpy&#x3D;&quot;o o 0&quot;&#x2F;&gt;
    &lt;axis xyz&#x3D;&quot;O 0 1&quot;&#x2F;&gt;
    &lt;limit lower&#x3D;&quot;-3.14&quot; upper&#x3D;&quot;3.14&quot; velocity&#x3D;&quot;1.0&quot;&#x2F;&gt;
&lt;&#x2F;joint&gt;</code></pre>

<p><strong>创建功能包</strong></p>
<pre class="language-none"><code class="language-none">catkin_create_pkg  mbot_description urdf xacro</code></pre>
<p><strong>安装rviz里的gui</strong></p>
<pre class="language-none"><code class="language-none">sudo apt-get install ros-melodic-joint-state-publisher-gui </code></pre>
<p><strong>检查 URDF 模型的整体结构</strong></p>
<pre class="language-none"><code class="language-none">urdf_to_graphiz mbot_base.urdf</code></pre>

<h1 id="xacro"><a href="#xacro" class="headerlink" title="xacro"></a>xacro</h1><p>xacro 相比于 urdf 的优点</p>
<blockquote>
<p>精简模型代码</p>
</blockquote>
<ul>
<li>创建宏定义</li>
<li>文件包含</li>
</ul>
<blockquote>
<p>提供可编程接口</p>
</blockquote>
<ul>
<li>常量</li>
<li>变量</li>
<li>数学计算</li>
<li>条件语句</li>
</ul>
<p><strong>常量定义</strong></p>
<pre class="language-none"><code class="language-none">&lt;xacro:property name&#x3D;&quot;M_PI&quot; value&#x3D;&quot;3.14159&quot;&#x2F;&gt;</code></pre>
<p><strong>常量使用</strong></p>
<pre class="language-none"><code class="language-none">&lt;origin xyz&#x3D;&quot;o0o&quot; rpy&#x3D;&quot;$&#123;M_PI&#x2F;2&#125;0 0&quot;&#x2F;&gt;</code></pre>

<p><strong>数学计算</strong></p>
<pre class="language-none"><code class="language-none">&lt;origin xyz&#x3D;&quot;0 $&#123;(motor_length+wheel_length)&#x2F;2&#125; o&quot; rpy&#x3D;&quot;o 0 0&quot;&#x2F;&gt;</code></pre>

<p><strong>宏定义</strong></p>
<pre class="language-none"><code class="language-none">&lt;xacro:macro name&#x3D;&quot;name&quot; params&#x3D;&quot;AB C&quot;&gt;
···
&lt;&#x2F;xacro:macro&gt;</code></pre>

<p><strong>宏调用</strong></p>
<pre class="language-none"><code class="language-none">&lt;name A&#x3D; &quot;A_value&quot; B&#x3D;&quot;B_value&quot; C&#x3D; &quot;C_value&quot;</code></pre>
<p><strong>文件包含</strong></p>
<pre class="language-none"><code class="language-none">&lt;xacro:include filename&#x3D;&quot;$(find mbot description)&#x2F;urdf&#x2F;mbot base gazebo.xacro&quot;&#x2F;&gt;</code></pre>
      
    </div>

  </div>

  <div class="article-footer">
    <div class="article-meta pull-left">

    
      

    <span class="post-categories">
      <i class="icon-categories"></i>
        <a href="/blog/categories/ROS-学习笔记/">ROS 学习笔记</a>
    </span>
    

    
    

    <span class="post-tags">
      <i class="icon-tags"></i>
        <a href="/blog/tags/ROS/">ROS</a>
    </span>
    

    </div>

    
  </div>
</article>



  <article>

  
    
    <h3 class="article-title"><a href="/blog/2021/04/12/2-ROS通信编程/"><span>2-ROS通信编程</span></a></h3>
    
  

  <div class="article-top-meta">
    <span class="posted-on">
      <a href="/blog/2021/04/12/2-ROS通信编程/" rel="bookmark">
        <time class="entry-date published" datetime="2021-04-12T12:39:03.000Z">
          2021-04-12
        </time>
      </a>
    </span>
  </div>


  

  <div class="article-content">
    <div class="entry">
      
        <h1 id="ROS-topic-编程"><a href="#ROS-topic-编程" class="headerlink" title="ROS topic 编程"></a>ROS topic 编程</h1><p>创建一个ROS工作空间并在工作空间内创建src源码路径</p>
<p>初始化这个工作空间</p>
<pre class="language-none"><code class="language-none">mkdir  -p catkin_ws&#x2F;src
cd catkin_ws&#x2F;src
catkin_init_workspace
cd ..
catkin_make</code></pre>
<p>在工作空间的根目录下编译并 设置环境变量 并检查是否设置正确</p>
<pre class="language-none"><code class="language-none">source devel&#x2F;setup.zsh
echo $ROS_PACKAGE_PATH</code></pre>

<h2 id="ROS-项目开发流程"><a href="#ROS-项目开发流程" class="headerlink" title="ROS 项目开发流程"></a>ROS 项目开发流程</h2><p><strong>$ catkin_create_pkg <package_name> [depend1] [depend2] [depend3]</package_name></strong></p>
<h4 id="创建并编译功能包"><a href="#创建并编译功能包" class="headerlink" title="创建并编译功能包"></a>创建并编译功能包</h4><pre class="language-none"><code class="language-none">cd catkin_ws&#x2F;src
catkin_create_pkg learning_communication rospy roscpp std_msgs std_srvs
cd ..   &#x2F;&#x2F;(编译一定是在工作空间的根目录)
catkin_make
source devel&#x2F;setup.zsh</code></pre>

<p>新增代码之后需要修改 ==CMakeLists.txt== </p>
<ol>
<li>设置需要编译的代码和生成可执行文件</li>
<li>设置链接库</li>
</ol>
<pre class="language-none"><code class="language-none">vi catkin_ws&#x2F;src&#x2F;learning_communication&#x2F;CMakeLists.txt

add_executable(string_publisher src&#x2F;string_publisher.cpp)
target_link_libraries(string_publisher $&#123;catkin_LIBRARIES&#125;)

add_executable(string_subscriber src&#x2F;string_subscriber.cpp)
target_link_libraries(string_subscriber $&#123;catkin_LIBRARIES&#125;)</code></pre>
<p>运行、检验</p>
<pre class="language-none"><code class="language-none">source devel&#x2F;setup.zsh

roscore &amp;

rosrun learning_communication string_publisher
rosrun learning_communication string_subscriber   &#x2F;&#x2F;新建一个终端</code></pre>
<h4 id="自定义-msg"><a href="#自定义-msg" class="headerlink" title="自定义 msg"></a>自定义 msg</h4><p>创建 msg 文件夹及文件</p>
<pre class="language-none"><code class="language-none">cd catkin_ws&#x2F;src&#x2F;learning_communication
mkdir msg
cd msg
touch PersonMsg.msg</code></pre>
<p>在 PersonMsg.msg 添加内容</p>
<pre class="language-none"><code class="language-none">string name
uint8  age
uint8  sex

uint8 unknown &#x3D; 0
uint8 male    &#x3D; 1
uint8 female  &#x3D; 2</code></pre>

<p>在 ==pachage.xml== 中添加功能包依赖</p>
<pre class="language-none"><code class="language-none">&lt;build_depend&gt;message_generation&lt;&#x2F;build_depend&gt;
&lt;exec_depend&gt;message_runtime&lt;&#x2F;exec_depend&gt;</code></pre>

<p>在 ==CMakeLists.txt==  中添加编译选项</p>
<p><code>find_package(... message_generation)</code></p>
<p><code>catkin_package(... message_runtime)</code></p>
<pre class="language-none"><code class="language-none">add_message_files(FILES PersonMsg.msg)
generate_messages(DEPENDENCIES std_msgs)</code></pre>

<pre class="language-none"><code class="language-none">add_executable(person_publisher src&#x2F;person_publisher.cpp)
target_link_libraries(person_publisher $&#123;catkin_LIBRARIES&#125;)
add_dependencies(person_publisher $&#123;PROJECT_NAME&#125;_gencpp)

add_executable(person_subscriber src&#x2F;person_subscriber.cpp)
target_link_libraries(person_subscriber $&#123;catkin_LIBRARIES&#125;)
add_dependencies(person_subscriber $&#123;PROJECT_NAME&#125;_gencpp)</code></pre>

<p>运行、检验</p>
<pre class="language-none"><code class="language-none">source devel&#x2F;setup.zsh
roscore &amp;

rosrun learning_communication person_publisher
rosrun learning_communication person_subscriber   &#x2F;&#x2F;新建一个终端</code></pre>

<h1 id="ROS-service-编程"><a href="#ROS-service-编程" class="headerlink" title="ROS service 编程"></a>ROS service 编程</h1><h4 id="自定义-srv"><a href="#自定义-srv" class="headerlink" title="自定义 srv"></a>自定义 srv</h4><p>创建 msg 文件夹及文件</p>
<pre class="language-none"><code class="language-none">cd catkin_ws&#x2F;src&#x2F;learning_communication
mkdir srv
cd srv
touch PersonSrv.srv</code></pre>
<p>在 PersonSrv.srv 添加内容</p>
<pre class="language-none"><code class="language-none">string name
uint8  age
uint8  sex

uint8 unknown &#x3D; 0
uint8 male    &#x3D; 1
uint8 female  &#x3D; 2

---
string result</code></pre>
<p>三横线以上是 request 内容 以下是 respond 内容</p>
<p>在 ==CMakeLists.txt== 添加一行</p>
<pre class="language-none"><code class="language-none">add_service_files(FILES PersonSrv.srv)</code></pre>
<p>其实还应该在package.xml中添加依赖。以及链接库，由于msg已经添加过，所以可以省</p>
<p>ROS查看节点类型一节该类型的结构体成员</p>
<pre class="language-none"><code class="language-none">rostopic type &#x2F;turtle1&#x2F;pose
rosmsg show turtlesim&#x2F;Pose

rostopic type &#x2F;turtle1&#x2F;cmd_vel
rosmsg show geometry_msgs&#x2F;Twist</code></pre>
<p><a target="_blank" rel="noopener" href="https://gitee.com/ChenBlue/linux/tree/master/ros/turtle_cmd/src">ROS topic code</a></p>

      
    </div>

  </div>

  <div class="article-footer">
    <div class="article-meta pull-left">

    
      

    <span class="post-categories">
      <i class="icon-categories"></i>
        <a href="/blog/categories/ROS-学习笔记/">ROS 学习笔记</a>
    </span>
    

    
    

    <span class="post-tags">
      <i class="icon-tags"></i>
        <a href="/blog/tags/ROS/">ROS</a>
    </span>
    

    </div>

    
  </div>
</article>



  <article>

  
    
    <h3 class="article-title"><a href="/blog/2021/04/12/5-机器视觉处理/"><span>5-机器视觉处理</span></a></h3>
    
  

  <div class="article-top-meta">
    <span class="posted-on">
      <a href="/blog/2021/04/12/5-机器视觉处理/" rel="bookmark">
        <time class="entry-date published" datetime="2021-04-12T12:39:03.000Z">
          2021-04-12
        </time>
      </a>
    </span>
  </div>


  

  <div class="article-content">
    <div class="entry">
      
        <h1 id="ROS-摄像头驱动及数据接口"><a href="#ROS-摄像头驱动及数据接口" class="headerlink" title="ROS 摄像头驱动及数据接口"></a>ROS 摄像头驱动及数据接口</h1><p><strong>安装启动摄像头</strong></p>
<pre class="language-none"><code class="language-none">sudo apt-get install ros-melodic-usb-cam
roslaunch usb_cam usb_cam-test.launch
rqt_image_view</code></pre>

<h2 id="摄像头参数的标定"><a href="#摄像头参数的标定" class="headerlink" title="摄像头参数的标定"></a>摄像头参数的标定</h2><p><strong>安装标定的功能包</strong></p>
<pre class="language-none"><code class="language-none">sudo apt-get install ros-melodic-camera-calibration</code></pre>
<h3 id="摄像头标定流程"><a href="#摄像头标定流程" class="headerlink" title="摄像头标定流程"></a>摄像头标定流程</h3><p><strong>启动摄像头</strong></p>
<pre class="language-none"><code class="language-none">roslaunch robot_vision usb_cam.launch</code></pre>

<p><strong>启动标定包</strong></p>
<pre class="language-none"><code class="language-none">rosrun camera_calibration cameracalibrator.py --size 8x6--square 0.024 image:&#x3D;&#x2F;usb_cam&#x2F;image_raw camera:&#x3D;&#x2F;usb_cam</code></pre>
<ol>
<li>size:标定棋盘格的内部角点个数，这里使用的棋盘一共有六行，每行有8个内部角点;</li>
<li>square:这个参数对应每个棋盘格的边长，单位是米;</li>
<li>image和camera:设置摄像头发布的图像话题。</li>
</ol>
<h1 id="ROS-OpenCV-图像处理方法及案例"><a href="#ROS-OpenCV-图像处理方法及案例" class="headerlink" title="ROS + OpenCV 图像处理方法及案例"></a>ROS + OpenCV 图像处理方法及案例</h1><p><strong>安装 OpenCV</strong></p>
<pre class="language-none"><code class="language-none">sudo apt-get install ros-melodic-vision-opencv libopencv-dev python-opencv</code></pre>

<pre class="language-none"><code class="language-none">graph LR
subgraph ROS
handler(&quot;CvBridge&quot;)--&gt;handler2(&quot;ROS Image Message&quot;)
handler2(&quot;ROS Image Message&quot;)--&gt;handler(&quot;CvBridge&quot;)
end
subgraph OpenCV
start(&quot;Opencv ipiimage&quot;)--&gt;handler(&quot;CvBridge&quot;)
handler(&quot;CvBridge&quot;)--&gt;start(&quot;Opencv ipiimage&quot;)
end</code></pre>

<p>ROS + OpenCV 最重要的就是 CvBridge 。通过这个将图像进行转化。所有的图像处理都是用opencv去处理的。</p>
<blockquote>
<p>imgmsg_to_cv2() : 将 ROS 图像消息转换成 OpenCV 图像数据</p>
<p>cv2_to_imgmsg(): 将 OpenCV格式的图像数据转换成 ROS 图像消息</p>
</blockquote>
<h1 id="ROS-Tensorflow-物体识别方法及案例"><a href="#ROS-Tensorflow-物体识别方法及案例" class="headerlink" title="ROS + Tensorflow 物体识别方法及案例"></a>ROS + Tensorflow 物体识别方法及案例</h1><p><strong>安装 TensorFlow</strong></p>
<pre class="language-none"><code class="language-none">sudo apt-get install python-pip python-dev python-virtualenv

virtualenv --system-site-packages ~&#x2F;tensorflow

source ~&#x2F;tensorflow&#x2F;bin&#x2F;activate

easy_install -U pip

pip install --upgrade tensorflow</code></pre>
<p><strong>安装功能包</strong></p>
<pre class="language-none"><code class="language-none">cd ~&#x2F;catkin_ws&#x2F;src

git clone https:&#x2F;&#x2F;github.com&#x2F;Kukanani&#x2F;vision msgs.git

git clone https:&#x2F;&#x2F;github.com&#x2F;osrf&#x2F;tensorflow_object_detector.git</code></pre>

<p><strong>物体识别</strong></p>
<pre class="language-none"><code class="language-none">roslaunch tensorflow_object_detector usb_cam_detector.launch</code></pre>



      
    </div>

  </div>

  <div class="article-footer">
    <div class="article-meta pull-left">

    
      

    <span class="post-categories">
      <i class="icon-categories"></i>
        <a href="/blog/categories/ROS-学习笔记/">ROS 学习笔记</a>
    </span>
    

    
    

    <span class="post-tags">
      <i class="icon-tags"></i>
        <a href="/blog/tags/ROS/">ROS</a>
    </span>
    

    </div>

    
  </div>
</article>



  <article>

  
    
    <h3 class="article-title"><a href="/blog/2021/04/12/6-机器人语音交互/"><span>6-机器人语音交互</span></a></h3>
    
  

  <div class="article-top-meta">
    <span class="posted-on">
      <a href="/blog/2021/04/12/6-机器人语音交互/" rel="bookmark">
        <time class="entry-date published" datetime="2021-04-12T12:39:03.000Z">
          2021-04-12
        </time>
      </a>
    </span>
  </div>


  

  <div class="article-content">
    <div class="entry">
      
        <h1 id="ROS-语音交互"><a href="#ROS-语音交互" class="headerlink" title="ROS 语音交互"></a>ROS 语音交互</h1><p><a target="_blank" rel="noopener" href="https://www.xfyun.cn/">去讯飞开放平台下载sdk包</a></p>
<p>注册并登录账号。然后点击控制台-&gt;创建应用</p>
<p><img src="https://note.youdao.com/yws/public/resource/f308e2317897e76c9fc04e78e81d758e/xmlnote/CDC5B6936442480CBB792878D33A7542/3851" alt="1"><br><img src="https://note.youdao.com/yws/public/resource/f308e2317897e76c9fc04e78e81d758e/xmlnote/C662A11215D544DA8AAE2DA6AD5607F3/3857" alt="2"></p>
<p><strong>拷贝并安装库</strong></p>
<pre class="language-none"><code class="language-none">sudo cp libmsc.so &#x2F;usr&#x2F;lib

sudo apt install sox

sudo apt install libsox-fmt-all</code></pre>
















      
    </div>

  </div>

  <div class="article-footer">
    <div class="article-meta pull-left">

    
      

    <span class="post-categories">
      <i class="icon-categories"></i>
        <a href="/blog/categories/ROS-学习笔记/">ROS 学习笔记</a>
    </span>
    

    
    

    <span class="post-tags">
      <i class="icon-tags"></i>
        <a href="/blog/tags/ROS/">ROS</a>
    </span>
    

    </div>

    
  </div>
</article>



  <article>

  
    
    <h3 class="article-title"><a href="/blog/2021/04/12/7-机器人SLAM建图/"><span>7-机器人SLAM建图</span></a></h3>
    
  

  <div class="article-top-meta">
    <span class="posted-on">
      <a href="/blog/2021/04/12/7-机器人SLAM建图/" rel="bookmark">
        <time class="entry-date published" datetime="2021-04-12T12:39:03.000Z">
          2021-04-12
        </time>
      </a>
    </span>
  </div>


  

  <div class="article-content">
    <div class="entry">
      
        <h1 id="常用的-SLAM-功能包应用"><a href="#常用的-SLAM-功能包应用" class="headerlink" title="常用的 SLAM 功能包应用"></a>常用的 SLAM 功能包应用</h1><h2 id="gmapping"><a href="#gmapping" class="headerlink" title="gmapping"></a>gmapping</h2><p><strong>gmapping 功能包</strong></p>
<ul>
<li>基于激光雷达</li>
<li>Rao-Blackwellized粒子滤波算法</li>
<li>二维栅格地图</li>
<li>需要机器人提供里程计信息</li>
<li>OpenSlam开源算法</li>
<li>输出地图话题:</li>
<li>nav_msgs/OccupancyGrid。</li>
</ul>
<pre class="language-none"><code class="language-none">graph TD
A(即时定位与地图建模 gmapping)

B(深度信息)--&gt;A

C(IMU信息)--&gt;A 

D(里程计信息)--&gt;A
</code></pre>
<p><strong><center>gmapping 功能包的总体框架</center></strong></p>
<p><strong>安装gmapping</strong></p>
<pre class="language-none"><code class="language-none">sudo apt-get install ros-melodic-gmapping</code></pre>
<p><strong><center>gmapping 功能包中的话题和服务</center></strong></p>
<table>
<thead>
<tr>
<th align="left"></th>
<th align="left">名称</th>
<th align="left">类型</th>
<th align="left">描述</th>
</tr>
</thead>
<tbody><tr>
<td align="left">Topic 订阅</td>
<td align="left">tf</td>
<td align="left">tf/tfMessage</td>
<td align="left">用于激光雷达坐标系，基座标系。里程计坐标系之间的变换</td>
</tr>
<tr>
<td align="left">Topic 订阅</td>
<td align="left">scan</td>
<td align="left">sensor_msgs/LaserScan</td>
<td align="left">激光雷达扫描数据</td>
</tr>
<tr>
<td align="left">Topic 发布</td>
<td align="left">map_metedata</td>
<td align="left">nav_msgs/MapMeteData</td>
<td align="left">发布地图Meta数据</td>
</tr>
<tr>
<td align="left">Topic 发布</td>
<td align="left">map</td>
<td align="left">nav_msgs/OccupancyGrid</td>
<td align="left">发布地图栅格数据</td>
</tr>
<tr>
<td align="left">Topic 发布</td>
<td align="left">~entropy</td>
<td align="left">std_msgs/Float64</td>
<td align="left">发布机器人姿态分布熵的估计</td>
</tr>
<tr>
<td align="left">Service</td>
<td align="left">dynamic_map</td>
<td align="left">nav_msgs/GetMap</td>
<td align="left">获取地图数据</td>
</tr>
</tbody></table>
<p><strong><center>gampping 功能包中的TF变换</center></strong></p>
<table>
<thead>
<tr>
<th></th>
<th>TF变换</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>必须的TF坐标变换</td>
<td><scan frame>-&gt;base_link</scan></td>
<td>激光雷达坐标系之间的变换</td>
</tr>
<tr>
<td></td>
<td>base_link-&gt;odom</td>
<td>基座标系与里程计坐标系之间的变换。一般由里程计节点发布</td>
</tr>
<tr>
<td>发布的TF坐标变换</td>
<td>map-&gt;odom</td>
<td>地图坐标系与机器人里程计坐标系之间的变换。估计机器人在地图中的位置</td>
</tr>
</tbody></table>
<p><strong>保存地图</strong></p>
<pre class="language-none"><code class="language-none">rosrun map_server map_saver -f cloister_gmapping</code></pre>
<h2 id="hector"><a href="#hector" class="headerlink" title="hector"></a>hector</h2><p><strong>hector 功能包</strong></p>
<ul>
<li>基于激光雷达</li>
<li>高斯牛顿方法</li>
<li>二维栅格地图</li>
<li><strong>不需要机器人提供里程计信息</strong></li>
<li>输出地图话题:</li>
<li>nav_msgs/OccupancyGrid。</li>
</ul>
<pre class="language-none"><code class="language-none">graph TD
A(即时定位与地图建模 hector)

B(深度信息)--&gt;A</code></pre>
<p><strong><center>hector_slam 功能包的总体框架</center></strong></p>
<p><strong>安装hector_slam</strong></p>
<pre class="language-none"><code class="language-none">$ git clone https:&#x2F;&#x2F;github.com&#x2F;tu-darmstadt-ros-pkg&#x2F;hector_slam.git</code></pre>
<p><strong><center>hector 功能包中的话题和服务</center></strong></p>
<table>
<thead>
<tr>
<th align="left"></th>
<th align="left">名称</th>
<th align="left">类型</th>
<th align="left">描述</th>
</tr>
</thead>
<tbody><tr>
<td align="left">Topic 订阅</td>
<td align="left">syscommand</td>
<td align="left">std_msgs/String</td>
<td align="left">系统命令</td>
</tr>
<tr>
<td align="left">Topic 订阅</td>
<td align="left">scan</td>
<td align="left">sensor_msgs/LaserScan</td>
<td align="left">激光雷达扫描数据</td>
</tr>
<tr>
<td align="left">Topic 发布</td>
<td align="left">map_metedata</td>
<td align="left">nav_msgs/MapMeteData</td>
<td align="left">发布地图Meta数据</td>
</tr>
<tr>
<td align="left">Topic 发布</td>
<td align="left">map</td>
<td align="left">nav_msgs/OccupancyGrid</td>
<td align="left">发布地图栅格数据</td>
</tr>
<tr>
<td align="left">Topic 发布</td>
<td align="left">slam_out_pose</td>
<td align="left">geometry_msgs/PoseStamped</td>
<td align="left">估计的机器人位置（没用协方差）</td>
</tr>
<tr>
<td align="left">Topic 发布</td>
<td align="left">poseupdate</td>
<td align="left">geometry_msgs/PoseWithCovarianceStamped</td>
<td align="left">估计的机器人位置（具有高斯估计的不确定性）</td>
</tr>
<tr>
<td align="left">Service</td>
<td align="left">dynamic_map</td>
<td align="left">nav_msgs/GetMap</td>
<td align="left">获取地图数据</td>
</tr>
</tbody></table>
<p><strong><center>hector 功能包中的TF变换</center></strong></p>
<table>
<thead>
<tr>
<th></th>
<th>TF变换</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>必须的TF坐标变换</td>
<td><scan frame>-&gt;base_link</scan></td>
<td>激光雷达坐标系之间的变换</td>
</tr>
<tr>
<td></td>
<td>base_link-&gt;odom</td>
<td>基座标系与里程计坐标系之间的变换。一般由里程计节点发布</td>
</tr>
<tr>
<td>发布的TF坐标变换</td>
<td>map-&gt;odom</td>
<td>地图坐标系与机器人里程计坐标系之间的变换。估计机器人在地图中的位置</td>
</tr>
</tbody></table>
<h2 id="cartographer"><a href="#cartographer" class="headerlink" title="cartographer"></a>cartographer</h2><p><strong>cartographer 功能包</strong></p>
<ul>
<li>2016年10月5日，谷歌开源</li>
<li>基于图网络的优化方法</li>
<li>二维或三维条件下的定位及建图功能</li>
<li>设计目的是在计算资源有限的情况下，实时获取相对较高精度的2D地图</li>
<li>主要基于激光雷达</li>
<li>后续会支持更多传感器和机器人平台,同时不断增加新的功能。</li>
</ul>
<p><strong>安装 cartographer</strong></p>
<pre class="language-none"><code class="language-none">$ sudo apt-get install ros-melodic-cartographer-*</code></pre>
<p><strong>保存地图</strong></p>
<pre class="language-none"><code class="language-none">$ rosservice call &#x2F;finish_trajectory 0
$ rosservice call &#x2F;write_state &quot;&#123;filename: &#39;$&#123;HOME&#125;&#x2F;mymap.pbstream&#39;&#125;&quot;
$ rosrun cartographer_ros cartographer_pbstream_to_ros_map-map_filestem&#x3D;$&#123;HOME&#125;&#x2F;mymap-pbstream_filename&#x3D;$&#123;HOME&#125;&#x2F;mymap.pbstream-resolution&#x3D;0.05
</code></pre>
<h2 id="rtabmap"><a href="#rtabmap" class="headerlink" title="rtabmap"></a>rtabmap</h2><p><strong>安装 rtabmap</strong></p>
<pre class="language-none"><code class="language-none">$ sudo apt-get install ros-melodic-rtabmap-ros</code></pre>
<p><strong>查看建图结果</strong></p>
<pre class="language-none"><code class="language-none">$ rtabmap-databaseViewer ~&#x2F;.ros&#x2F;rtabmap.db</code></pre>



      
    </div>

  </div>

  <div class="article-footer">
    <div class="article-meta pull-left">

    
      

    <span class="post-categories">
      <i class="icon-categories"></i>
        <a href="/blog/categories/ROS-学习笔记/">ROS 学习笔记</a>
    </span>
    

    
    

    <span class="post-tags">
      <i class="icon-tags"></i>
        <a href="/blog/tags/ROS/">ROS</a>
    </span>
    

    </div>

    
  </div>
</article>



  <article>

  
    
    <h3 class="article-title"><a href="/blog/2021/04/12/8-机器人自主导航/"><span>8-机器人自主导航</span></a></h3>
    
  

  <div class="article-top-meta">
    <span class="posted-on">
      <a href="/blog/2021/04/12/8-机器人自主导航/" rel="bookmark">
        <time class="entry-date published" datetime="2021-04-12T12:39:03.000Z">
          2021-04-12
        </time>
      </a>
    </span>
  </div>


  

  <div class="article-content">
    <div class="entry">
      
        <h1 id="ROS-中的导航框架"><a href="#ROS-中的导航框架" class="headerlink" title="ROS 中的导航框架"></a>ROS 中的导航框架</h1><p><a target="_blank" rel="noopener" href="https://blog.csdn.net/qq_40247550/article/details/108051916">https://blog.csdn.net/qq_40247550/article/details/108051916</a></p>

      
    </div>

  </div>

  <div class="article-footer">
    <div class="article-meta pull-left">

    
      

    <span class="post-categories">
      <i class="icon-categories"></i>
        <a href="/blog/categories/ROS-学习笔记/">ROS 学习笔记</a>
    </span>
    

    
    

    <span class="post-tags">
      <i class="icon-tags"></i>
        <a href="/blog/tags/ROS/">ROS</a>
    </span>
    

    </div>

    
  </div>
</article>



  <article>

  
    
    <h3 class="article-title"><a href="/blog/2021/04/12/ros 学习笔记/"><span>ros 学习笔记</span></a></h3>
    
  

  <div class="article-top-meta">
    <span class="posted-on">
      <a href="/blog/2021/04/12/ros 学习笔记/" rel="bookmark">
        <time class="entry-date published" datetime="2021-04-12T12:39:03.000Z">
          2021-04-12
        </time>
      </a>
    </span>
  </div>


  

  <div class="article-content">
    <div class="entry">
      
        <h1 id="1-环境搭建及海龟示例demo"><a href="#1-环境搭建及海龟示例demo" class="headerlink" title="1-环境搭建及海龟示例demo"></a><a href="https://chenblue.gitee.io/blog/2021/04/12/1-%E7%8E%AF%E5%A2%83%E6%90%AD%E5%BB%BA%E5%8F%8A%E6%B5%B7%E9%BE%9F%E7%A4%BA%E4%BE%8Bdemo/">1-环境搭建及海龟示例demo</a></h1><h1 id="2-ROS-通信编程"><a href="#2-ROS-通信编程" class="headerlink" title="2-ROS 通信编程"></a><a href="https://chenblue.gitee.io/blog/2021/04/12/2-ROS%E9%80%9A%E4%BF%A1%E7%BC%96%E7%A8%8B/">2-ROS 通信编程</a></h1><h1 id="3-lunch启动文件及可视化"><a href="#3-lunch启动文件及可视化" class="headerlink" title="3-lunch启动文件及可视化"></a><a href="https://chenblue.gitee.io/blog/2021/04/12/3-lunch%E5%90%AF%E5%8A%A8%E6%96%87%E4%BB%B6%E5%8F%8A%E5%8F%AF%E8%A7%86%E5%8C%96/">3-lunch启动文件及可视化</a></h1><h1 id="4-机器人模型-URDF-及-XACRO"><a href="#4-机器人模型-URDF-及-XACRO" class="headerlink" title="4-机器人模型 URDF 及 XACRO"></a><a href="https://chenblue.gitee.io/blog/2021/04/12/4-%E6%9C%BA%E5%99%A8%E4%BA%BA%E6%A8%A1%E5%9E%8B%20URDF%20%E5%8F%8A%20XACRO/">4-机器人模型 URDF 及 XACRO</a></h1><h1 id="5-机器视觉处理"><a href="#5-机器视觉处理" class="headerlink" title="5-机器视觉处理"></a><a href="https://chenblue.gitee.io/blog/2021/04/12/5-%E6%9C%BA%E5%99%A8%E8%A7%86%E8%A7%89%E5%A4%84%E7%90%86/">5-机器视觉处理</a></h1><h1 id="6-机器人语音交互"><a href="#6-机器人语音交互" class="headerlink" title="6-机器人语音交互"></a><a href="https://chenblue.gitee.io/blog/2021/04/12/6-%E6%9C%BA%E5%99%A8%E4%BA%BA%E8%AF%AD%E9%9F%B3%E4%BA%A4%E4%BA%92/">6-机器人语音交互</a></h1><h1 id="7-机器人SLAM建图"><a href="#7-机器人SLAM建图" class="headerlink" title="7-机器人SLAM建图"></a><a href="https://chenblue.gitee.io/blog/2021/04/12/7-%E6%9C%BA%E5%99%A8%E4%BA%BASLAM%E5%BB%BA%E5%9B%BE/">7-机器人SLAM建图</a></h1><h1 id="8-机器人自主导航"><a href="#8-机器人自主导航" class="headerlink" title="8-机器人自主导航"></a><a href="https://chenblue.gitee.io/blog/2021/04/12/8-%E6%9C%BA%E5%99%A8%E4%BA%BA%E8%87%AA%E4%B8%BB%E5%AF%BC%E8%88%AA/">8-机器人自主导航</a></h1><h1 id="树莓派安装-ROS"><a href="#树莓派安装-ROS" class="headerlink" title="树莓派安装 ROS"></a><a target="_blank" rel="noopener" href="http://note.youdao.com/noteshare?id=6c4ebb6ca630eaa68dc782adb0e07958&sub=B32696BC0F7940C7903E782444EE4F49">树莓派安装 ROS</a></h1>
      
    </div>

  </div>

  <div class="article-footer">
    <div class="article-meta pull-left">

    
      

    <span class="post-categories">
      <i class="icon-categories"></i>
        <a href="/blog/categories/ROS-学习笔记/">ROS 学习笔记</a>
    </span>
    

    
    

    <span class="post-tags">
      <i class="icon-tags"></i>
        <a href="/blog/tags/ROS/">ROS</a>
    </span>
    

    </div>

    
  </div>
</article>




<nav class="pagination">
  
  <a href="/blog/" class="pagination-prev">上一页</a>
  
  
</nav>
    </main>

    <footer class="site-footer">
  <p class="site-info">
    Proudly powered by <a href="https://hexo.io/" target="_blank">Hexo</a> and
    Theme by <a href="https://github.com/CodeDaraW/Hacker" target="_blank">Hacker</a>
    </br>
    
    &copy; 2023 ChenBlue
    
  </p>
</footer>
    
    
  </div>
</div>
</body>
</html>